package main

import "fmt"

func mightPanic() {
	fmt.Println("Function mightPanic starting.")
	// 引发panic
	panic("Something went wrong!")
	fmt.Println("Function mightPanic ending. This line will not be executed.")
}

func div_panic(a float64, b float64) float64 {
	if b == 0 {
		// 除数不能为0，不能除以0
		panic("can not div 0!")
		return 0.0
	}
	return a / b
}

func main() {
	fmt.Println("Main function starting.")
	defer func() {
		if r := recover(); r != nil {
			fmt.Println("Recovered in main: ", r)
		}
	}()

	// mightPanic()
	div_panic(12, 0)

	fmt.Println("Main function ending.")
}
